/**
 * Created with IntelliJ IDEA.
 * Description: 数组
 * User: cjc
 * Date: 2025-03-03
 * Time: 20:03
 */
public class Test {
    public static void main(String[] args) {
        int[] arr1 = new int[5];//动态初始化
        int[] arr3 = new int[]{1,2,3,4,5};//静态初始化
        int[] arr2 = {1,2,3,4,5};//简化版静态初始化
        arr1[1] = 20;
        System.out.println(arr1[1]);//数组中元素访问
        for (int i = 0; i < 5; i++) {
            System.out.print(arr3[i]+ " ");
        }
        System.out.println();
        //增强型 for 循环
        for (int x: arr3) {
            System.out.print(x+ " ");
        }
        System.out.println();
        //用方法遍历数组
        for (int i = 0; i < arr3.length; i++) {
            System.out.print(arr3[i]+ " ");
        }
    }

}
